﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using XNAGameFeatures.Input;

namespace XNAGameFeatures.Shapes
{
    public class ShapeRectangle : Shape2D
    {
        public Color Color { get; set; }
        private Vector2 _pos;

        private Rectangle _rect;

        public Vector2 Position
        {
            get { return _pos; }
            set { _pos = value; }
        }
        

        public int Width
        {
            get { return _rect.Width; }
            set { _rect.Width = value; }
        }

        public int Height
        {
            get { return _rect.Height; }
            set { _rect.Height = value; }
        }


        public ShapeRectangle(Vector2 pos)
        {
            _pos = pos;
            Color = Color.Black;
        }

        public ShapeRectangle(int w, int h, Color color, Vector2 pos)
        {
            _rect = new Rectangle((int) pos.X, (int) pos.Y, w, h);
            Color = color;
            _pos = pos;
        }

        public override void Draw(GameTime gameTime)
        {
            ScreenManager.SpriteBatch.Begin();
            ScreenManager.SpriteBatch.Draw(SquareSprite, _rect, Color);
            ScreenManager.SpriteBatch.End();
        }

        public override void LoadContent()
        {
            SquareSprite = new Texture2D(ScreenManager.GraphicsDevice, 1, 1);

            SquareSprite.SetData(new[] {Color.White});
        }

        public override void UnloadContent()
        {
        }

        public override void Update(GameTime gameTime)
        {
            _rect.X = (int)_pos.X;
            _rect.Y = (int)_pos.Y;
        }

        public override void HandleInput(InputManager input)
        {
        }
    }
}
